<?php
header("Content-type:text/html;charset=utf-8");
// header("Content-type:text/xml");
require_once "./APP/config/config.php";
define ('BASEDIR',__DIR__);
spl_autoload_register ('my_autoloader');
function  my_autoloader ( $class ) {
	if($class!='APP\DOMDocument'){
		$str = BASEDIR.'/'.str_replace('\\','/',$class).'.class.php';
		require_once $str;
	}	
}
$sfzcode=!empty($_GET['sfzcode']) ? trim($_GET['sfzcode']) : null;
$type=!empty($_GET['type'] )? trim($_GET['type']) : null;
$channel=!empty($_GET['channel']) ? trim($_GET['channel']) : null;
$id=!empty($_GET['id']) ? trim($_GET['id']) : null;
$userId=!empty($_GET['userid']) ? trim($_GET['userid']) : null;
if( $sfzcode && $type && $channel && $id==null){
	$obj=new APP\Control(1,$type);
	$sql_str=$obj->selectStr($sfzcode,$channel);
 	$db= APP\Factory::createObj("APP\db\Db");
 	$query=$db->query($sql_str)->fetch_array();	
 	if($query){
	 	$xml_arr=$obj->onQuery($query);
	 	$xml_arr['type']=$type;
	 	$xml_arr['channel']=$channel;
	 	$xml_arr['sfzcode']=$sfzcode;
	 	$obj->createXml($xml_arr);

	}else{
		$obj->createXml();
	}

}else if($sfzcode && $type && $channel && $id && $userId){

	$obj=new APP\Control(2,$type);
	$flag= $obj->updateSQL($id,$userId,$sfzcode,$channel);



}





?>